app=$1
t=$2

if [ "$app" == "" ]; then 
  echo "./run-11.sh 目录名"
  exit 1;
fi

if [ "$t" == "" ]; then
  echo "运行xxl-job执行器。需要指定端口"
  exit 1;
fi

app=`echo ${app//\//}`


start_sh="/app/java/start.sh"
if [ -f "/app/java/$app/start.sh" ]; then 
    start_sh="/app/java/$app/start.sh"
    echo "start脚本: $start_sh"
fi

docker kill $app && docker rm $app

echo "正在启动 $app ..."
docker run   --name $app \
  -m 1024m \
  -d \
  -v "$(pwd)/$app":/app \
  -v  $PWD/u-hosts.sh:/app/u-hosts.sh  \
  -v "$start_sh":/app/exec.sh \
  -w /app  \
  -p $t:$t \
  --add-host=nacos:172.17.134.92 \
  --add-host=dc-app:172.18.0.1 \
  --add-host=amy:172.17.134.92 \
  --add-host=mysql:172.17.134.92 \
  --add-host=mongo:172.17.134.92 \
  --add-host=redis:172.17.134.92 \
  --add-host=rabbitmq:172.17.134.92 \
  --add-host=es:172.17.134.92 \
  --add-host=minio:172.17.134.92 \
 --link mp-gateway-api:mp-gateway-api \
  openjdk:11.0.10-jdk-oraclelinux7  /bin/bash  /app/exec.sh $app
